package com.gitee.wsl.flow.transform

import kotlinx.coroutines.flow.Flow

/**
 * Filters flow elements that don't match a given instance along with a provided predicate
 */
@Suppress("UNCHECKED_CAST")
inline fun <reified R> Flow<*>.filterIsInstance(crossinline predicate: suspend (R) -> Boolean): Flow<R> =
    filter { it is R && predicate(it) } as Flow<R>
